What happens if you let the browser access a TXT file? For example, to visit Localhost/test/test.txt, the browser will direct the contents of the TXT file
displayed directly on the browser instead of downloading it.
However, not all files will
The following describes how to download a TXT file in a browser using PHP. Because the current browser can recognize the txt document format, if only a text link is provided for the txt document, the content of the txt file is displayed in a new
Click to download the TXT document (go to) in the PHP browser ). Because the current browser can recognize the txt document format, if only a text link is provided for the txt document, the content of the txt file is displayed in a new window after
["Note: Other files want to be set as download files, and the method described below is consistent"]since the current browser can already recognize the TXT document format, if only to make a text link to the TXT document, click to open a new window
Since the current browser can already recognize the TXT document format, if only to make a text link to the TXT document, click to open a new window to display the contents of the TXT file, and can not achieve the purpose of click to download. Of
The answer is: when the server uses the php feature (function) to include any file, the source of the file to be included is not strictly filtered, so that it can contain a malicious file, we can construct this malicious file to achieve the evil
Because the current browser can recognize the txt document format, if only a text link is provided for the txt document, the content of the txt file is displayed in a new window after clicking it, click Download cannot be implemented. Of course, the
Because the current browser can recognize the txt document format, if only a text link is provided for the txt document, the content of the txt file is displayed in a new window after clicking it, click Download cannot be implemented. Of course, the
Because now the browser has been able to identify TXT document format, if only to do a text link txt document, click on just open a new window to display TXT file content, and can not achieve the purpose of the download. Of course, the solution to
download some files in PHP, usually to hide the file's true download address only need this, otherwise this will increase the burden on the server, rather than directly provide the address of the software.
A simple php file download source code,
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.